package com.ieasy.module.system.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.ieasy.basic.dao.ExtFieldEntity;

@Entity @Table(name="ieasy_sys_vote")
public class VoteEntity extends ExtFieldEntity {

	private String subject ;
	
	private Integer sum = new Integer(0) ;
	
	private Integer weight = new Integer(0) ;
	
	/** 是否主标题 */
	private Boolean isTitle = Boolean.TRUE ;
	
	/** true：关闭投票 */
	private boolean status = Boolean.TRUE ;
	
	/** 投票类型：true为多选，false为当选 */
	private boolean voteType ;
	
	private VoteEntity vote ;
	
	public boolean isVoteType() {
		return voteType;
	}

	public void setVoteType(boolean voteType) {
		this.voteType = voteType;
	}

	public Boolean getIsTitle() {
		return isTitle;
	}

	public void setIsTitle(Boolean isTitle) {
		this.isTitle = isTitle;
	}

	private Set<VoteEntity> votes = new HashSet<VoteEntity>() ;

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public Integer getSum() {
		return sum;
	}

	public void setSum(Integer sum) {
		this.sum = sum;
	}

	@ManyToOne
	@JoinColumn(name = "pid")
	public VoteEntity getVote() {
		return vote;
	}

	public void setVote(VoteEntity vote) {
		this.vote = vote;
	}
	
	@OneToMany(mappedBy = "vote", fetch = FetchType.LAZY)
	@OrderBy("weight asc")
	public Set<VoteEntity> getVotes() {
		return votes;
	}

	public Integer getWeight() {
		return weight;
	}

	public void setWeight(Integer weight) {
		this.weight = weight;
	}

	public void setVotes(Set<VoteEntity> votes) {
		this.votes = votes;
	}
}
